package com.sr.recitewords.service.sysLanguageCategory;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sr.recitewords.common.enums.TableNamePrefixEnum;
import com.sr.recitewords.datasource.entities.SysLanguage;
import com.sr.recitewords.datasource.entities.SysLanguageCategory;
import com.sr.recitewords.datasource.mappers.SysLanguageCategoryMapper;
import com.sr.recitewords.datasource.mappers.SysLanguageMapper;
import com.sr.recitewords.utils.IdentifierGeneratorUtil;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysLanguageCategoryServiceImpl extends ServiceImpl<SysLanguageCategoryMapper, SysLanguageCategory> implements SysLanguageCategoryService {
    @Override
    public boolean addSysLanguageCategory(SysLanguageCategory sysLanguageCategory) {
        sysLanguageCategory.setLanguageCategoryId(IdentifierGeneratorUtil.getOwnId(TableNamePrefixEnum.SYS_LANGUAGE_CATEGORY));
        sysLanguageCategory.setCreateDate(new Date());
        return save(sysLanguageCategory);
    }

    @Override
    public boolean addSysLanguageCategoryList(List<SysLanguageCategory> sysLanguageCategoryList) {
        Date date = new Date();
        for (SysLanguageCategory sysLanguageCategory : sysLanguageCategoryList) {
            sysLanguageCategory.setLanguageCategoryId(IdentifierGeneratorUtil.getOwnId(TableNamePrefixEnum.SYS_LANGUAGE_CATEGORY));
            sysLanguageCategory.setCreateDate(date);
        }
        return saveBatch(sysLanguageCategoryList);
    }
}
